import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const withRefreshOnListRoute = (WrappedComponent) => {
  return (props) => {
    const location = useLocation();
    useEffect(() => {
      if (location.pathname.includes('/chatDetail')) {
        const Elements = document.getElementById('sheld')
        if (Elements) {
          if (Elements.style.display === 'none') {
            Elements.style.display = 'block';
            Elements.style.display = 'flex';
          } else {
            Elements.style.display = 'block';
            Elements.style.display = 'flex';
          }
        }
      }
    }, [location]);

    return <WrappedComponent {...props} />;
  };
};

export default withRefreshOnListRoute;